package com.example.myapplication.data.realm

import android.app.Application
import io.realm.Realm
import io.realm.RealmConfiguration

/**
 * 描    述：
 * 作    者：fantianwen
 * 时    间：2019/2/14  3:39 PM
 */

object RealmUtils {

    var version: Long = 6

    var oldVersion: Long = -1

    fun initRealm(context: Application) {
        Realm.init(context)

        val builder = RealmConfiguration
            .Builder()
            .name("tokencat")
            .schemaVersion(version)

        val config = addModule(builder)
            .migration(Migration())
            .build()

        Realm.getInstance(config)
        Realm.setDefaultConfiguration(config)

    }

    private fun addModule(builder: RealmConfiguration.Builder): RealmConfiguration.Builder {

        //登陆账号，邮件账户详情
//        builder.addModule(EmailInfoModule())
        return builder
    }

}